home *** CD-ROM | disk | FTP | other *** search
- Path: avalon.net!news
- From: craiger@avalon.net [Craig Miller]
- Newsgroups: comp.lang.c
- Subject: Re: given: char foo[80]; there is no such thing as element foo[80] correct? (i.e. foo[80] = '\0' is beyond the array boundary)
- Date: 20 Mar 1996 16:37:41 GMT
- Organization: Avalon Networks Inc.
- Message-ID: <4ipc8l$t3g@arthur.avalon.net>
- References: <3148DBB6.1353@hawaii.edu> <4ih0p0$7q5@vip.cybercity.dk>
- Reply-To: craiger@avalon.net [Craig Miller]
- NNTP-Posting-Host: sioux-city-dial1.avalon.net
- X-Newsreader: IBM NewsReader/2 v1.2.5
-
- In <4ih0p0$7q5@vip.cybercity.dk>, monsted@cybercity.dk (Monsted) writes:
-
- >>Yes or no on this, I just recently got confused by two different books. I
- >>assume that the declaration foo[80] allocates storage for elements 0-79.
- >>A string could be terminated by doing something like foo[79] = '\0', but
- >>foo[80] = '\0' would be invalid because such an element does not exist.
- >>Just looking for confirmation that I'm right here. A simple Y or N will
- >>do thanks.
-
- It depends on if you mean "does foo[80] exist" or if you mean "can I write
- data to foo[80]".. foo[80] does _NOT_ exist, but you can write data to it.
- You will be changing the byte immediately following foo[], which could be
- another variable, or worse yet, program code. Been there, done that, it's ugly.
-
- >>-Recently confused C programmer
- Most of us are. :)
-
- Craig
-